<template>
  <el-dialog
    title="查看日报"
    :visible.sync="dialogVisible"
    :append-to-body="true"
    :close-on-click-modal="false"
    @close="handleColse"
    width="40%"
  >
    <el-form :model="dataForm"
             :rules="dataForm"
             ref="dataForm"
             size="small"
             label-width="80px">
      <div style="margin-top: -14px; max-height: 500px;" v-html="dataForm.contentXml"></div>
<!--      <el-form-item label="日报内容" prop="content">-->
<!--&lt;!&ndash;        <el-input v-model="dataForm.content" type="textarea"></el-input>&ndash;&gt;-->
<!--       -->
<!--&lt;!&ndash;        <quill-editor :content="dataForm.contentXml" :isShowToolbar="isShowToolbar" @onEditorChange="onEditorChange"></quill-editor>&ndash;&gt;-->
<!--      </el-form-item>-->
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button
        @click="dialogVisible = false"
        size="small">取消</el-button>
      <el-button
        type="primary"
        v-if="!isDisabled"
        :loading="dialogLoading"
        @click="handleSubmitForm"
        size="small">确定</el-button>
    </div>
  </el-dialog>
</template>
<script>
  import {queryDetailrecord} from '@/api/dailyweekly/workflow'
  import QuillEditor from '@/components/QuillEditor'
  export default {
    data() {
      return {
        dialogVisible: false,
        dialogLoading: false,
        dataForm: {
          content: '',
          id: ''
        },
        isShowToolbar: false,
        isDisabled: false
      }
    },
    components: {
      QuillEditor
    },
    methods: {
      init (val, isDisabled) {
        this.isDisabled = isDisabled
        this.dataForm.id = val
        this.dialogVisible = true
        this.$nextTick(() => {
          this.$refs['dataForm'].resetFields()
          this.queryDaily()
        })
      },
      async queryDaily () {
        const data = await queryDetailrecord(this.dataForm.id)
        if (data.code === 200) {
          this.dataForm = data.data
        }
        this.dialogLoading = false
      },
      handleSubmitForm () {
        this.dialogLoading = true
        this.editDaily()
      },
      onEditorChange (val) {
        this.dataForm.contentXml = val.html
      },
      handleColse () {
        this.dialogVisible = false
      }
    }
  }
</script>
<style scoped>
</style>
